//
//  TYHVidoViewController.m
//  OpenPractice
//
//  Created by tanyuehong on 16/2/29.
//  Copyright © 2016年  lijinghua. All rights reserved.
//

#import "TYHUserHeaderView.h"
#import "TYHUserCenterCell.h"
#import "TYHMyMineController.h"
#import "TYHLoginController.h"


@interface TYHMyMineController () <UITableViewDelegate,UITableViewDataSource,TYHUserHeaderViewDelegate>

@property (nonatomic, weak)UITableView *userTableView;
@property (nonatomic, strong)TYHUserHeaderView *userHeaderView;
@property (nonatomic, strong)NSArray *ModelArr;

@end

@implementation TYHMyMineController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initData];
    [self initUserTableView];
}

- (void)refresh {
    
}

- (void)initUserTableView {
    UITableView *userTabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    userTabView.delegate   = self;
    userTabView.dataSource = self;
    userTabView.rowHeight = 50;
    userTabView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [userTabView setBackgroundColor:kOPBackgroundColor];
    userTabView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    userTabView.tableHeaderView = self.userHeaderView;
    userTabView.rowHeight = 44;
    [self.view addSubview:userTabView];
    self.userTableView = userTabView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES];
}

- (void)initData {
    NSMutableArray *firstArray = [NSMutableArray arrayWithArray:@[@{
                                                                      @"title":@"商城",
                                                                      @"mainIcon":@"usercenter_supermarket"
                                                                      },
                                                                  @{
                                                                      @"title":@"少年听闻",
                                                                      @"mainIcon":@"usercenter_knowledgeUniverse"
                                                                      },
                                                                  @{
                                                                      @"title":@"黑板报",
                                                                      @"mainIcon":@"usercenter_blackboard",
                                                                      },
                                                                  @{
                                                                      @"title":@"帮帮币",
                                                                      @"mainIcon":@"usercenter_mall",
                                                                      },
                                                                  @{
                                                                      @"title": @"帮帮公益",
                                                                      @"mainIcon":@"usercenter_gongyi",
                                                                      },
                                                                  @{
                                                                      @"title":@"学币",
                                                                      @"mainIcon":@"usercenter_coin",
                                                                      },
                                                                  @{
                                                                      @"title":@"优惠券",
                                                                      @"mainIcon":@"usercenter_coupon",
                                                                      }
                                                                  ]
                                  ];
    self.ModelArr = firstArray;
 
}

- (void)loginBtnClick:(UIButton *)btn {
    TYHLoginController *loginControler = [[TYHLoginController alloc] init];
    loginControler.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:loginControler animated:YES completion:nil];
}

- (TYHUserHeaderView *)userHeaderView {
    if (!_userHeaderView) {
        _userHeaderView = [[TYHUserHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 250)];
        _userHeaderView.delegate = self;
    }
    return _userHeaderView;
}

#pragma mark tableViewDelegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.ModelArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TYHUserCenterCell *cell = [TYHUserCenterCell cellWithtableView:tableView];
    return cell;
}

@end
